document.addEventListener('DOMContentLoaded', function() {
    // Menu item selection
    const menuItems = document.querySelectorAll('.menu-item');
    
    menuItems.forEach(item => {
        item.addEventListener('click', function() {
            // Remove active class from all menu items
            menuItems.forEach(i => i.classList.remove('active'));
            
            // Add active class to clicked item
            this.classList.add('active');
            
            // Get the menu text to update the main content title
            const menuText = this.querySelector('.menu-text').textContent;
            document.querySelector('.main-content h1').textContent = menuText + ' Content';
        });
    });
    
    // Sidebar collapse functionality
    const collapseButton = document.querySelector('.collapse-button');
    const sidebar = document.querySelector('.sidebar');
    const menuTexts = document.querySelectorAll('.menu-text');
    const profileInfo = document.querySelector('.profile-info');
    
    collapseButton.addEventListener('click', function() {
        sidebar.classList.toggle('collapsed');
        
        if (sidebar.classList.contains('collapsed')) {
            sidebar.style.width = '80px';
            menuTexts.forEach(text => text.style.display = 'none');
            profileInfo.style.display = 'none';
            collapseButton.querySelector('img').style.transform = 'rotate(180deg)';
        } else {
            sidebar.style.width = '194px';
            menuTexts.forEach(text => text.style.display = 'block');
            profileInfo.style.display = 'block';
            collapseButton.querySelector('img').style.transform = 'rotate(0deg)';
        }
    });
}); 